#ifndef IODEVICEWITHTHREADSUPPORT_H
#define IODEVICEWITHTHREADSUPPORT_H

#include "IODeviceWithoutThreadSupport.h"
#include <BDThread.h>
#include <BDMutex.h>

class IODeviceWithThreadSupport :
	public IODeviceWithoutThreadSupport, public BDThread
{
public:
	IODeviceWithThreadSupport(IODeviceType type, IODeviceContext* context);
	virtual ~IODeviceWithThreadSupport();

	virtual void SendOperation(IODeviceOperation operation, unsigned int param);

	virtual bool GetOperation(IODeviceOperation& operation, unsigned int& param);

	virtual void OnOperation(IODeviceOperation operation, unsigned int param);

protected:

	void* Run(void* data);

	bool m_bFlag;

	BDList<std::pair<IODeviceOperation, unsigned int>> m_listOperation;

	BDMutex m_mutex;

	void Start();

	void Stop();
};

#endif